package com.ruoyi.quartz.task;

import com.ruoyi.system.service.ICompanyContentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

@Component("resetCompanyInfoTask")
public class ResetCompanyInfoTask {

    private final Logger log = LoggerFactory.getLogger(ResetCompanyInfoTask.class);

    @Autowired
    private ICompanyContentService companyContentService;

    /**
     * 具体执行内容
     */
    public void execute() {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start("resetCompanyInfoTask");
        log.info("开始执行刷新公司和页面缓存任务");
        // 清空目录下所有文件
        companyContentService.resetCompany();
        log.info("刷新公司缓存结束");
        companyContentService.resetHtmlContent();
        log.info("刷新页面缓存结束");
        stopWatch.stop();
        log.info("刷新公司和页面缓存完成,总耗时:{}秒", stopWatch.getTotalTimeSeconds());
    }

}
